﻿using Syc.Domain;
using Syc.Repository;
using EFBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Syc.Application
{
    public class UserApp
    {
        private IUserRepository service = new UserRepository();
        public UsersEntity CheckLogin(string username, string password)
        {
            UsersEntity userEntity = service.FindEntity(t => t.UserCode == username);
            if (userEntity != null)
            {
                if (userEntity.EnabledMark == true)
                {
                    if (password == userEntity.PassWord)
                    {
                        return userEntity;
                    }
                    else
                    {
                        throw new Exception("密码不正确，请重新输入");
                    }
                }
                else
                {
                    throw new Exception("账户被系统锁定,请联系管理员");
                }
            }
            else
            {
                throw new Exception("账户不存在，请重新输入");
            }
        }
    }
   
}
